package vn.student;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class ViewInputTextBox extends Activity implements View.OnClickListener{
	String title = "";
	String oldValue = "";
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.input_editor);
		title =this.getIntent().getExtras().getString("title");
		oldValue =this.getIntent().getExtras().getString("oldValue");
		TextView titleTextBox = (TextView) findViewById(R.id.titleLabel);
		if(title.equals("email"))
			titleTextBox.setText("Edit email address");
		else if(title.equals("phone"))
			titleTextBox.setText("Edit phone number");
		else if(title.equals("add"))
			titleTextBox.setText("Edit address");
		else if(title.equals("web"))
			titleTextBox.setText("Edit website address");
		else if(title.equals("note"))
			titleTextBox.setText("Edit note");
		else if(title.equals("className"))
			titleTextBox.setText("Edit class name");
		else if(title.equals("location"))
			titleTextBox.setText("Edit location");
		else if(title.equals("contactName"))
			titleTextBox.setText("Edit contact name");
		EditText inputTextBox = (EditText) findViewById(R.id.inputNewValueTexbox);
		inputTextBox.setText(oldValue);
		Button btn = (Button) findViewById(R.id.saveBtn);
		btn.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		EditText inputTextBox = (EditText) findViewById(R.id.inputNewValueTexbox);
		Intent intent = new Intent();
		Bundle bundle = new Bundle();
		bundle.putString("title",title);
		bundle.putString("newValue", inputTextBox.getText().toString());
		intent.putExtras(bundle);
		this.setResult(RESULT_OK, intent);
		this.finish();
	}
}
